#ifndef _DRV_EVENT_H
#define _DRV_EVENT_H

#include "DRV_Neul.h"

#define EVENT_WAIT_ALWAYS    0xFFFF
#define EVENT_WAIT_DEFAULT   60000

#define ITEMS_OF(x)				(sizeof(x)/sizeof((x)[0]))
#define STRLEN(string)				(sizeof(string)-1)

#define MAX_ARGC    6
#define ARGC_FREE(sArgc, sArgv) do{ \
				int k = 0; \
				for(k=0;k<sArgc;k++){ \
					if(sArgv[k]){ \
						free(sArgv[k]); \
						sArgv[k] = NULL; \
					} \
				} \
		}while(0)

typedef enum{
    NONE = 0,
    RISE_STATE = 1,
    ING_STATE = 2,
    OVER_STATE = 3,
}EN_STATE;


#pragma pack(1)

typedef struct{
	T_MUTEX mutex;
	OS_SEMAPHORE_T sem;
	int event;
	int state; //0. nothing, 1.gen event, 2.proc ing, 3.proc over
	int reqArgc;
	char *reqArgv[MAX_ARGC];
	int retCode;
	int rspArgc;
	char *rspArgv[MAX_ARGC];
    int (*evfunc)(int reqArgc, char *reqArgv[], int *retCode,int *rspArgc,char *rspArgv[]);
}ST_EVENT;

#pragma pack()

int initEvent();
int RecvEvent(EN_DEV_TYPE type, int event, int *argc, char *argv[], int timeout);
int SendEvent(EN_DEV_TYPE type, int event, int state, int argc, char *argv[]);
int DevEventProc(EN_DEV_TYPE type);
/**
@brief EC600查询事件对外接口函数
@param
	- event 事件类型
	- sargc 查询事件参数个数
	- sargv 查询事件参数内容，要求内容为字符串格式
	- rargc 接收事件参数个数
    - rargv 接收事件参数内容，要求内容为字符串格式
    - timeout 超时时间
@return none
**/
int Ec600sDoEvent(int event,int sargc,char *sargv[],int *rargc,char *rargv[],int timeout);

#endif

